﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ObjectSweptVolume.CApObjectSweptVolumeItem
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.ComponentModel;
using System.Windows.Media;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ObjectSweptVolume;

public class CApObjectSweptVolumeItem : INotifyPropertyChanged
{
  private string m_name;
  private ImageSource m_icon;

  public CApObjectSweptVolumeItem(ITxObject obj)
  {
    this.Object = obj;
    this.m_name = this.Object.Name;
  }

  public event PropertyChangedEventHandler PropertyChanged;

  public void NotifyPropertyChanged(string propertyName)
  {
    PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
    if (propertyChanged == null)
      return;
    propertyChanged((object) this, new PropertyChangedEventArgs(propertyName));
  }

  public ITxObject Object { get; private set; }

  public string Name
  {
    get => this.m_name;
    private set
    {
      if (!(this.m_name != value))
        return;
      this.m_name = value;
      this.NotifyPropertyChanged(nameof (Name));
    }
  }

  public ImageSource Icon
  {
    get
    {
      if (this.m_icon == null && this.IsValid())
        this.m_icon = TxIconManager.the().GetObjectImageSource(this.Object, true);
      return this.m_icon;
    }
    private set
    {
      if (this.m_icon == value)
        return;
      this.m_icon = value;
      this.NotifyPropertyChanged(nameof (Icon));
    }
  }

  public void UpdateName()
  {
    if (!this.IsValid())
      return;
    this.Name = this.Object.Name;
  }

  private bool IsValid() => this.Object != null && this.Object.IsValid();
}
